package com.synnex.mobile.servier.core.msgBoard.bo;

import com.synnex.mobile.generic.core.util.ObjectUtil;
import com.synnex.mobile.servier.core.msgBoard.dto.MsgDTO;
import org.apache.commons.httpclient.util.DateUtil;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: kerryf
 * To change this template use File | Settings | File Templates.
 */
public class MsgBo implements Serializable {

    protected Integer id;
    protected String user;
    protected String content;

    protected int seq;
    protected String updateDate;
    private String entryDate;

    public String getEntryDate() {
        return entryDate;
    }

    public void setEntryDate(String entryDate) {
        this.entryDate = entryDate;
    }

    public static MsgBo createInstance(MsgDTO msgDTO) {
        MsgBo msgBo = ObjectUtil.copyProperties(msgDTO, MsgBo.class);
        msgBo.setEntryDate(DateUtil.formatDate(msgDTO.getEntryDate(),"yyyy-mm-dd hh:MM:ss"));
        return msgBo;
    }

    public static List<MsgBo> createListInstances(List<MsgDTO> msgDTOs) {
        List<MsgBo> msgBos = new ArrayList<MsgBo>();
        if (msgDTOs != null) {
            for (int i=0;i<msgDTOs.size();i++) {
                MsgBo bo = createInstance(msgDTOs.get(i));
                bo.setSeq(i+1);
                msgBos.add(bo);
            }
        }
        return msgBos;
    }


    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getUser() {
        return user;
    }

    public void setUser(String user) {
        this.user = user;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public int getSeq() {
        return seq;
    }

    public void setSeq(int seq) {
        this.seq = seq;
    }

    public String getUpdateDate() {
        return updateDate;
    }

    public void setUpdateDate(String updateDate) {
        this.updateDate = updateDate;
    }
}
